<?php

namespace apiend\controllers;

use Yii;
use apiend\components\Controller;
use yii\data\ActiveDataProvider;
use apiend\models\ShareForm;
use common\models\share\ShareLog;

class ShareController extends Controller {

    /**
     * Declares the allowed HTTP verbs.
     * Please refer to [[VerbFilter::actions]] on how to declare the allowed verbs.
     * @return array the allowed HTTP verbs.
     */
    protected function verbs() {
        return [
            '*' => ['POST']
        ];
    }

    public function actionCreate() {
        $this->redirect($url);
        $model = new ShareForm();
        if (!$model->load(Yii::$app->request->post(), '')) {
            parent::warning('视频动态更新时提交的数据未加载成功');
        }
        $model->user_id = $this->token->user_id;
        $model->device_id = $this->token->device_id;
        return $model->share();
    }

    public function actionUpdate($id) {
        $model = ShareLog::findOne($id);
        $model->status = ShareLog::STATUS_ACTIVE;
        return $model->save();
    }

}
